﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Box2D.XNA;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;

namespace Spinning.Spinning.Entity.Items
{
    class AddTimeItem : StaticBarrier
    {
        public AddTimeItem()
        {
            Physic_Type = PhysicType.Item;
            ZIndex = Constants.item;
        }

        public override void OnCreatBody(World world, Unitity.PhysicConnectManager connectManager)
        {
            base.OnCreatBody(world, connectManager);
            _fixture.SetSensor(true);
        }

        public override void BeginContact(PhysicSprite other)
        {
            base.BeginContact(other);
            
            if (other.Physic_Type == PhysicType.Player && !istouched)
            {
                SingleGamePlayer player = (SingleGamePlayer)other;
                //OnTounched(player);
                //Alpha = 0;
                istouched = true;
            }
        }

        public override void OnTounched(SingleGamePlayer player)
        {
            player.AddLifeTime(ItemLevel);
        }

        protected override void UpdateSelf(GameTime gameTime)
        {
            int delta = gameTime.ElapsedGameTime.Milliseconds;

            if (istouched)
            {
                this.BodyPosiotion = new Vector2(body.Position.X - 2000, body.Position.Y);
            }
        }
    }
}
